package com.dxy.df.core.config;

import com.dxy.df.constants.ConstStrings;
import com.dxy.df.core.config.properties.EvnProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Objects;

/**
 * <p>class_name: EvnPropertiesFactory</p>
 * <p>package: com.dxy.df.core.evn</p>
 * <p>describe: env</p>
 * <p>@author: wangsheng@dxy.cn</p>
 * <p>@date: 2019-07-19 </p>
 **/
@Component
public class EvnPropertiesConfig {

    private EvnProperties evnProperties;
    private String env;

    public EvnPropertiesConfig(EvnProperties evnProperties) {
        this.evnProperties = evnProperties;
    }

    @PostConstruct
    private void init() {
        if (Objects.equals(ConstStrings.ENV_LOCAL, System.getProperty(ConstStrings.SPRING_PROFILES_ACTIVE))
                || Objects.equals(ConstStrings.ENV_DEV, System.getProperty(ConstStrings.SPRING_PROFILES_ACTIVE))) {
            env = ConstStrings.ENV_LOCAL;
        } else if (Objects.equals(ConstStrings.ENV_TEST, System.getProperty(ConstStrings.SPRING_PROFILES_ACTIVE))) {
            env = ConstStrings.ENV_TEST;
        } else if ( Objects.equals(ConstStrings.ENV_UAT, System.getProperty(ConstStrings.SPRING_PROFILES_ACTIVE))) {
            env = ConstStrings.ENV_UAT;
        } else {
            env = ConstStrings.ENV_PRD;
        }
    }


    public String getEnv() {
        return env;
    }

    public String getBizUcAuthDomain() {
        return  evnProperties.getBizUcAuthDomain();
    }

    public String  getSimPluginLocation(){
        return evnProperties.getSimPluginLocation();
    }

}
